////////////////////////////////////////////////////////////////////////////////
///////// Product Market Competition and Convertible Debt Financing ////////////
///////// Cheng Lei, Evgeny Lyandres, Chris Veld, Ying Xia /////////////////////
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
* Date: April 27, 2024
* This do file contains code generating results for Tables 9 and 10
* Please define the path for datasets and the path for storing results before running the following program. 
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
* Use the issue-level sample of convertible bonds
* [Convertible_Characteristics_Sample]

use "Path\Convertible_Characteristics_Sample.dta", clear

* Control Variables for firm characteristics
global control size lage cash i.divd i.rep cf tangib capex mb rda Vol_12 

********************************************************************************
*Table 9 Competitive Threats and Length of Call Protection Periods
********************************************************************************
*Panel A - Table 9

* Model 1
reghdfe length fld , absorb(i.icode50) vce(cluster gvkey) keepsingleton
estimates store a1

* Model 2
reghdfe length fld i.r144 lmrates i.blig i.ig lnm proceedsmv1 i.r415 i.ppdum sales capex , absorb(i.icode50) vce(cluster gvkey) keepsingleton
estimates store a2

* Model 3
reghdfe length fld i.r144 lmrates i.blig i.ig lnm proceedsmv1 i.r415 i.ppdum sales capex , absorb(i.icode50 i.fyear) vce(cluster gvkey) keepsingleton
estimates store a3

esttab  a1 a2 a3  using "Path\Table_9_Panel_A.csv", b(3) t(2) scalars("ll Log lik.") pr2(4) ar2(4) starlevels(* 0.10 ** 0.05 *** 0.01)  replace nogaps

* Panel B - Table 9
mean length
mean length, over(frank)
ttest length, by(fdif)

********************************************************************************


********************************************************************************
* Table 10 Competitive Threats and Delta of Convertible Bonds
********************************************************************************
* Panel A - Table 10

* Model 1
reghdfe delta1 fld  , absorb(icode50 fyear) vce(cluster gvkey) keepsingleton
estimates store a1

* Model 2
reghdfe delta1 fld $control lnm i.calld2 i.ig i.blig i.r144 i.r415 proceedsmv1 i.ppdum amihud runup , absorb(icode50 fyear) vce(cluster gvkey) keepsingleton
estimates store a2

* Model 3
reghdfe delta1 fld $control lnm i.ig i.blig i.r144 i.r415 proceedsmv1 i.ppdum amihud runup if calld2 ==1, absorb(icode50 fyear) vce(cluster gvkey) keepsingleton
estimates store a3

* Model 4
reghdfe delta1 fld $control lnm i.ig i.blig i.r144 i.r415 proceedsmv1 i.ppdum amihud runup if calld2 ==0, absorb(icode50 fyear) vce(cluster gvkey) keepsingleton
estimates store a4


esttab  a1 a2 a3 a4  using "Path\Table_10_Panel_A.csv", b(3) t(2) scalars("ll Log lik.") pr2(4) ar2(4) starlevels(* 0.10 ** 0.05 *** 0.01)  replace nogaps

* Panel B - Table 10

mean delta1, over(frank)
mean delta1 if calld2 == 1, over(frank)
mean delta1 if calld2 == 0, over(frank)

ttest delta1, by(fdif)
ttest delta1 if calld2 == 1, by(fdif)
ttest delta1 if calld2 == 0, by(fdif)

********************************************************************************

////////////////////////////////////////////////////////////////////////////////
* The above codes generate the result, and the format of table is finalised in Excel. 
* Keepsingleton allows the estimation to be conducted based on the full sample. The results are unchanged if running without this requirement. 
////////////////////////////////////////////////////////////////////////////////



